package scheduledtasks.parscorn;



import scheduledtasks.entity.TaskObj;

import java.util.Date;


/**
 * 【月份解析]
 *
 * @author tiny
 * @version 1.0
 * @company bc
 * @copyright (c) 2022 bcInc. All rights reserved.
 * @date 2022-11-08 16:00:26
 * @since
 */

public class MonthParse extends ParseAbstract {

    @Override
    public boolean pars(String cron, TaskObj obj) {
        String cronstr=ParsUntil.getcron(cron,4);
        /*执行时间*/
        Date date=new Date(obj.getTime());
        /*现在*/
        Date dateNow=new Date(System.currentTimeMillis());
        if(cronstr.equals("*") ){
           return   getParseAbstract().pars(cron,obj);
        }
        if(cronstr.split("/").length==1){
           if(Integer.valueOf(cronstr)==dateNow.getMonth()){
               return  getParseAbstract().pars(cron,obj);
           }
        }else {
            if(dateNow.getMonth()-date.getMonth()>=Integer.valueOf(cronstr.split("/")[1])){
              return getParseAbstract().pars(cron, obj);
            }
        }
        return false;
    }



}
